<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="root" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>年度总计</title>
<link href="${root}/static/css/bootstrap.min.css" rel="stylesheet"
	type="text/css" />
<link href="${root}/static/css/treeview.min.css" rel="stylesheet"
	type="text/css" />
<script type="text/javascript" src="${root}/static/js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="${root}/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${root}/static/js/echarts.min.js"></script>
<script type="text/javascript">
	$(function() {
		var xdatas = [];
		var ydatas = [];
		var url = "${root}/chart/company";
		$.ajax({
			async : false,
			type : "GET",
			url : url,
			success : function(res) {
				if (res.code == "500") {
					alert(res.message);
					$("#app").hide();
				} else {
					xdatas.length = 0; //清空数组
					ydatas.length = 0; //清空数组
					for (var i = 0; i < res.name.length; i++) {
						xdatas.push(res.name[i]);
						ydatas.push(res.value[i]);
					}
				}
			}
		});
		//产生绘制工具对象 基于绘制层
		var myChart = echarts.init(document.getElementById("app"));
		//参数设置 图片参数数据等等
		var option = {
			//标题
			title : {
				text : "业务员总销售数据"
			},
			xAxis : {
				name : "业务员",
				data : xdatas
			},
			yAxis : {
				name : "销售金额"
			},
			series : [ {
				name : "销售金额",
				type : "line",
				data : ydatas
			} ],
			tooltip : {
				show : true
			}
		};
		//根据设置绘图参数 绘制指定的图形
		myChart.setOption(option);
	});
</script>
</head>
<body>
	<div id="app" class="container-fluid"
		style="width: 800px; height: 500px; border: solid 1px #ccc;"></div>
</body>
</html>
